package com.ehome.mobile.controller;

import com.ehome.mobile.R;
import com.ehome.mobile.bo.StatusBO;
import com.ehome.mobile.model.Status;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

public class StatusActivity extends Activity {

	private StatusBO statusBO = new StatusBO();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_status);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.menu_status, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		Intent intent;
		
		switch (item.getItemId()) {
			case R.id.menu_logout:
				intent = new Intent(getApplicationContext(), LoginActivity.class);
				startActivity(intent);
				finish();
				break;
			case R.id.menu_configurations:
				intent = new Intent(getApplicationContext(), ConfigurationsActivity.class);
				startActivity(intent);
				finish();
				break;
		}
		return true;
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		statusBO.close();
	}

	public void setStatus(View view) {
		Status status = new Status();
		boolean changedStatus = statusBO.setStatus(status);

		if (changedStatus) {

		} else {
			TextView msgError = (TextView) findViewById(R.id.configuration_msg);
			msgError.setText(R.string.status_error);
		}
	}
}